﻿@model string
@{
    Layout = ViewBag.Layout ?? "~/Views/Shared/EditorTemplates/_TR.cshtml";

    ViewData.TemplateInfo.HtmlFieldPrefix = ViewData.TemplateInfo.HtmlFieldPrefix.Replace(ViewData.ModelMetadata.PropertyName, "").Trim('.');
    var propertyName = ViewData["name"] == null ? ViewData.ModelMetadata.PropertyName : ViewData["name"].ToString();
    var setting = Kooboo.CMS.Common.Runtime.EngineContext.Current.Resolve<Kooboo.CMS.Account.Persistence.ISettingProvider>().Get();


    var editorHtmlAttributes = Html.GetUnobtrusiveValidationAttributes(propertyName, ViewData.ModelMetadata)
         .Merge("autocomplete", ViewData["autocomplete"] ?? "on")
         .Merge("data-val-regex-pattern", setting.PasswordStrength)
         .Merge("data-val-regex", setting.PasswordInvalidMessage)
         .Merge("data-val", "true");
    var htmlAttributes = ViewBag.HtmlAttributes;
    if (htmlAttributes != null)
    {
        if (htmlAttributes is IDictionary<string, object>)
        {
            editorHtmlAttributes.Merge((IDictionary<string, object>)htmlAttributes);
        }
        else
        {
            editorHtmlAttributes.Merge(new RouteValueDictionary(htmlAttributes));
        }
    }
}
@Html.Password(propertyName, Model, editorHtmlAttributes)

@Html.ValidationMessage(ViewData.ModelMetadata, new { name = ViewData["name"] })
@if (!string.IsNullOrEmpty(ViewData.ModelMetadata.Description))
{
    <em class="tip">@Html.Raw(ViewData.ModelMetadata.Description.Localize())</em>
}